home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / bbsutil / cmpbbs10.zip / CMPBBS.BAS next >
BASIC Source File  |  1990-02-26  |  14KB  |  341 lines

  1. DECLARE SUB BreakFileName (FileSpec$, DrvPath$, Prefix$, Extension$, ForJoining%)
  2. DECLARE SUB FindLast (LookIn$, LookFor$, WhereFound%, NumFinds%)
  3. DECLARE SUB TRIM (TRIM.PARM$)
  4. DECLARE SUB TrimTrail (TRIM.PARM$, TRIM.THIS$)
  5. DEFINT A-Z
  6. DIM BBSList$(200), Headers$(200), DirStartCol(200)                   ' 022490
  7. TRUE = -1
  8. FALSE = 0
  9. FOR I = 1 TO 200                                                     ' 022490
  10.    DirStartCol(I) = 1                                                ' 022490
  11. NEXT                                                                 ' 022490
  12. MasterStartCol = 1                                                   ' 022490
  13. MasterList$ = "UPLOADS.DIR"
  14. OutFile$ = "NEWFILES.DIR"
  15. NumNewLists = 0
  16. ConfigFile$ = "CMPBBS.CFG"
  17.  
  18. PassedArguments$ = COMMAND$
  19. PassedArguments$ = UCASE$(PassedArguments$)
  20. X = INSTR(PassedArguments$, "/B")
  21. RunBatch = (X > 0)
  22. IF RunBatch THEN
  23.    PassedArguments$ = LEFT$(PassedArguments$, X - 1) + RIGHT$(PassedArguments$, LEN(PassedArguments$) - X - 1)
  24. END IF
  25. X = INSTR(PassedArguments$, "/SHARE")
  26. SHARING = (X > 0)
  27. IF SHARING THEN
  28.    PassedArguments$ = LEFT$(PassedArguments$, X - 1) + RIGHT$(PassedArguments$, LEN(PassedArguments$) - X - 1)
  29. END IF
  30. IF PassedArguments$ <> "" THEN
  31.    ConfigFile$ = PassedArguments$
  32. END IF
  33.  
  34. ON ERROR GOTO 40000
  35. IF SHARING THEN
  36.    OPEN ConfigFile$ FOR INPUT SHARED AS #1
  37. ELSE
  38.    OPEN ConfigFile$ FOR INPUT AS #1
  39. END IF
  40. ON ERROR GOTO 0
  41. WHILE NOT EOF(1)
  42.    LINE INPUT #1, A$
  43.    X$ = LEFT$(A$, 1)
  44.    IF X$ <> "" AND X$ <> "*" THEN
  45.       A$ = UCASE$(A$)
  46.       IF LEFT$(A$, 12) = "/MASTERLIST=" THEN
  47.          MasterList$ = MID$(A$, 13)
  48.          CALL TRIM(MasterList$)
  49.       END IF
  50.       IF LEFT$(A$, 9) = "/ADDLIST=" THEN
  51.          NewList$ = MID$(A$, 10)
  52.          CALL TRIM(NewList$)
  53.          NumNewLists = NumNewLists + 1
  54.          BBSList$(NumNewLists) = NewList$
  55.       END IF
  56.       IF LEFT$(A$, 8) = "/HEADER=" THEN
  57.          Headers$(NumNewLists) = MID$(A$, 9)
  58.          CALL TRIM(Headers$(NumNewLists))
  59.       END IF
  60.       IF LEFT$(A$, 9) = "/OUTFILE=" THEN
  61.          OutFile$ = MID$(A$, 10)
  62.          CALL TRIM(OutFile$)
  63.       END IF
  64.       IF LEFT$(A$, 6) = "/SHARE" THEN
  65.          SHARING = TRUE
  66.       END IF
  67.       IF LEFT$(A$, 13) = "/DIRSTARTCOL=" THEN                        ' 022490
  68.          X$ = MID$(A$, 14)                                           ' 022490
  69.          CALL TRIM(X$)                                               ' 022490
  70.          DirStartCol(NumNewLists) = VAL(X$)                          ' 022490
  71.       END IF                                                         ' 022490
  72.       IF LEFT$(A$, 16) = "/MASTERSTARTPOS=" THEN                     ' 022490
  73.          X$ = MID$(A$, 15)                                           ' 022490
  74.          CALL TRIM(X$)                                               ' 022490
  75.          MasterStartCol = VAL(X$)                                    ' 022490
  76.       END IF                                                         ' 022490
  77.       IF LEFT$(A$, 10) = "/OUTCATAT=" THEN                           ' 022690
  78.          X$ = MID$(A$, 11)                                           ' 022690
  79.          CALL TRIM(X$)                                               ' 022690
  80.          OutCatAt = VAL(X$)                                          ' 022690
  81.       END IF                                                         ' 022690
  82.    END IF
  83. WEND
  84. CLOSE 1
  85.  
  86. PRINT "CMPBBS version 1.0 Feb 26, 1990 copyright (c) 1990 by Ken Goosens"
  87. PRINT "A SysOp utility to compare BBS file lists"
  88. PRINT
  89. PRINT "On this run"
  90. PRINT "Configuration file used ....... "; ConfigFile$
  91. PRINT "Name of master list of files... "; MasterList$
  92. PRINT "File names begin in column....."; MasterStartCol              ' 022490
  93. PRINT "# of file lists to process ...."; NumNewLists
  94. PRINT "Writing list of new files to... "; OutFile$
  95. PRINT "Adding category code at column.";                             ' 022690
  96. IF OutCatAt > 0 THEN                                                 ' 022690
  97.    PRINT OutCatAt                                                    ' 022690
  98. ELSE                                                                 ' 022690
  99.    PRINT " <none>"                                                   ' 022690
  100. END IF                                                               ' 022690
  101. PRINT
  102. IF NOT RunBatch THEN
  103.    INPUT "A to abort, anything else runs"; ANS$
  104.    ANS$ = UCASE$(ANS$)
  105.    IF ANS$ = "A" THEN
  106.       END
  107.    END IF
  108. END IF
  109.  
  110. ON ERROR GOTO 40010
  111. FileIn$ = MasterList$
  112. IF SHARING THEN
  113.    OPEN MasterList$ FOR INPUT SHARED AS #1
  114. ELSE
  115.    OPEN MasterList$ FOR INPUT AS #1
  116. END IF
  117. ON ERROR GOTO 0
  118.  
  119. GOSUB BuildCRC
  120.  
  121. OPEN OutFile$ FOR OUTPUT AS #2
  122.  
  123. AddToNew = TRUE
  124. NumFilesAdded = 0
  125. FOR ix = 1 TO NumNewLists
  126.    PRINT "Processing BBS list "; BBSList$(ix);
  127.    ON ERROR GOTO 40100
  128.    FileIn$ = BBSList$(ix)
  129.    StartCol = DirStartCol(ix)                                        ' 022490
  130.    IF SHARING THEN
  131.       OPEN BBSList$(ix) FOR INPUT SHARED AS #1
  132.    ELSE
  133.       OPEN BBSList$(ix) FOR INPUT SHARED AS #1
  134.    END IF
  135.    ON ERROR GOTO 0
  136.    IF ERC > 0 THEN
  137.       ERC = 0
  138.       PRINT " not found - skipping"
  139.    ELSE
  140.       CatCode$ = ""                                                  ' 022690
  141.       IF Headers$(ix) <> "" THEN                                     ' 022690
  142.          PRINT #2, " "; Headers$(ix)                                 ' 022690
  143.          IF OutCatAt > 0 THEN                                        ' 022690
  144.             X = INSTR(Headers$(ix), "M! ")                           ' 022690
  145.             IF X > 0 THEN                                            ' 022690
  146.                X$ = MID$(Headers$(ix), X + 3)                        ' 022690
  147.                CALL BreakFileName(X$, DrvPath$, CatCode$, Ext$, 0)   ' 022690
  148.                CatCode$ = LEFT$(CatCode$, 3)                         ' 022690
  149.                IF LEN(CatCode$) < 3 THEN                             ' 022690
  150.                   CatCode$ = CatCode$ + SPACE$(3 - LEN(CatCode$))    ' 022690
  151.                END IF                                                ' 022690
  152.             END IF                                                   ' 022690
  153.          END IF                                                      ' 022690
  154.       END IF                                                         ' 022690
  155.       GOSUB ProcessList
  156.    END IF
  157. NEXT
  158.  
  159. END
  160.  
  161. BuildCRC:
  162.  
  163.    WorkName$ = SPACE$(12)
  164.    WorkComp$ = WorkName$                                             ' 022490
  165.    CRCMaster$ = ""
  166.    FileCRC$ = MKI$(0)
  167.    AddToNew = FALSE
  168.    PRINT
  169.    PRINT "Indexing "; MasterList$;
  170.    StartCol = MasterStartCol                                         ' 022490
  171.    GOSUB ProcessList
  172.  
  173. RETURN
  174.  
  175. ProcessList:
  176.  
  177.    AddedAtStart = NumFilesAdded
  178.    NumRead = 0
  179.    AddCat = (CatCode$ <> "")
  180.    CutOffCat = OutCatAt + LEN(CatCode$) - 1
  181.    PrintAt = POS(0) + 1
  182.    ON ERROR GOTO 40020
  183.    WHILE NOT EOF(1)
  184. 4     LINE INPUT #1, A$
  185.       NumRead = NumRead + 1
  186.       LOCATE , PrintAt
  187.       PRINT NumRead;
  188.       IF LEN(A$) < StartCol THEN                                     ' 022490
  189.          GOTO NotAFile                                               ' 022490
  190.       END IF                                                         ' 022490
  191.       IF StartCol > 1 THEN                                           ' 022490
  192.          A$ = MID$(A$, StartCol)                                     ' 022490
  193.       END IF                                                         ' 022490
  194.       IF INSTR("/[]|<>+=;, ?*", LEFT$(A$, 1)) > 0 THEN
  195.          GOTO NotAFile
  196.       END IF
  197.       Y = INSTR(A$ + " ", " ")
  198.       IF Y > 13 THEN                                                 ' 022690
  199.          GOTO NotAFile                                               ' 022490
  200.       END IF                                                         ' 022490
  201.       LSET WorkName$ = A$
  202.       X = LEN(A$)
  203.       IF X < 12 THEN
  204.          MID$(WorkName$, X + 1) = "            "
  205.       END IF
  206.       Y = INSTR(WorkName$, " ")
  207.       Z = INSTR(WorkName$, ".")